<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>党务政务村务公开</title>
  <script type="text/javascript" src="../frame/assets/js/lib/jquery.min.js"></script>
  <script src="https://apps.bdimg.com/libs/jquery/2.1.4/jquery.min.js"></script>
  <script src="../frame/layui/lay/modules/layer.js"></script>
  <link rel="stylesheet" href="../frame/layui/lay/modules/layer/default/layer.css">
  <link rel="stylesheet" href="../frame/layui/css/layui.css"  media="all">
</head>
<body style="width: 100%;height: 100%">
        <div id="title" style="text-align: center">1</div>
        <img src="" id="imgs" style="margin-left: 200px;"  />
        <div id="context">1</div>

<script>
    const context = document.querySelector("#context");
    console.log(context);
    console.log(context.innerHTML);
</script>
</body>
<script type="text/javascript" src="../frame/layui/layui.js" charset="utf-8"></script>
<script>
   $(function (){
       var url = location.search; //这一条语句获取了包括问号开始到参数的最后，不包括前面的路径
       var params = url.substr(1);//去掉问号
       var pa = params.split("&");
       var s = new Object();
       for(var i = 0; i < pa.length; i ++){
           s[pa[i].split("=")[0]] = unescape(pa[i].split("=")[1]);
       }

       $.ajax({
           type:"get",//post或者get，非必须
           url:"/showaffairs1",//必须的
           dataType:"json",//text/xml/json，非必须
           success:function(data){//回调函数，非必须
               $.each(data,function(index,value){
                   if(value.id==s.id){
                        $("#context").html(value.context);
                       $("#title").text(value.title);
                       document.getElementById("imgs").src =value.img;
                        return;
                   }
               });
           }
       });
   });
</script>
</html>
